package com.laf.manage.controller.user;


import cn.hutool.core.collection.CollUtil;
import com.laf.common.core.controller.BaseController;
import com.laf.common.core.domain.R;
import com.laf.manage.domain.po.Point;
import com.laf.manage.service.IPointService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 点位管理Controller
 *
 * @author zian
 * @date 2024-10-30
 */
@Slf4j
@RequiredArgsConstructor
@Api(tags = "点位管理管理")
@RestController("userPointController")
@RequestMapping("/user/points")
public class PointController extends BaseController {
    private final IPointService pointService;

    /**
     * 查询点位管理列表
     */
    @ApiOperation("查询点位管理列表")
    @GetMapping("/list")
    public R<List<Point>> list() {
        List<Point> list = pointService.list();
        if (CollUtil.isEmpty(list)) {
            return R.ok(new ArrayList<>());
        }
        return R.ok(list);
    }

    @GetMapping("{id}")
    @ApiOperation("获取点位详情")
    public R<Point> getPointById(@PathVariable Long id) {
        Point point = pointService.getById(id);
        return R.ok(point);
    }
}
